package com.wc.AlgoOJ_train.train5_数据结构.c4_二叉树.DS0406_光头强的魔法瓶;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

/**
 * @Author congge
 * @Date 2024/3/3 11:43
 * @description http://43.138.190.70:8888/p/DS0406
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int n, x;
    static ArrayList<Integer> a = new ArrayList<>();
    static Set<Integer> set = new HashSet<>();

    public static void main(String[] args) {
        n = sc.nextInt();
        a.add(0);
        a.add(1000000001);
        set.add(0);
        set.add(1000000001);
        for (int i = 1; i <= n; i++) {
            String op = sc.next();
            x = sc.nextInt();
            int minI = queryMin(x);
            int maxI = queryMax(x);
            out.println(a.get(minI) + " " + a.get(maxI));
            if (op.equals("add")) {
                if (!set.contains(x)) {
                    set.add(x);
                    a.add(maxI, x);
                }
            } else if (op.equals("del")) {
                if (set.contains(x)) {
                    set.remove(x);
                    a.remove(maxI - 1);
                }
            }


        }
        out.flush();
    }

    static int queryMin(int x) {
        int l = 0, r = a.size();
        int res = 0;
        while (l <= r) {
            int mid = l + r >> 1;
            if (a.get(mid) < x) {
                res = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
        return res;
    }

    static int queryMax(int x) {
        int l = 0, r = a.size();
        int res = 0;
        while (l <= r) {
            int mid = l + r >> 1;
            if (a.get(mid) > x) {
                res = mid;
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        return res;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}